	<?php if( !empty($arBranch) ): ?>
		
        <?php foreach($arBranch as $tree): ?>
			
            <?php if( $level == 1 ): ?>

				<?php include_partial('tree/tree', array('arBranch' => $tree['children'], 'level' => 2)); ?>

            <?php elseif( $level == 2 ): ?>
				<li>
					<?php if( isset($tree['_default']) ) { ?>
						
						<?php echo link_to($tree['obj']->getName(), 'textmodule/page?id=' . $tree['_default']['obj']->getObjId()); ?>
						
					<?php } else if( $tree['obj']->getObjId() == 0):?>
					
						<?php if( $tree['obj']->getLabel() == 'photos' ): ?>
							<?php echo link_to($tree['obj']->getName(), 'gallery/show') ?>
						<?php else: ?>
							<?php echo link_to($tree['obj']->getName(), '#', array('onclick' => 'jQuery(this).parent().children(":last").toggle()')) ?>
						<?php endif ?>
						
					<?php else: ?>
						<?php if($tree['obj']->getObjType() == 1): ?>
							<?php if( !$tree['obj']->getName() ): ?>
								<?php echo link_to($tree['obj']->getObjId(), 'textmodule/page?id=' . $tree['obj']->getObjId()); ?>
							<?php else: ?>
								<?php echo link_to($tree['obj']->getName(), 'textmodule/page?id=' . $tree['obj']->getObjId()); ?>
							<?php endif; ?>
						<?php elseif( $tree['obj']->getObjType() == 2 ): ?>
							<?php if( !$tree['obj']->getName() ): ?>
								<?php echo link_to($tree['obj']->getObjId(), 'gallery/show?id=' . $tree['obj']->getObjId()) ?>
							<?php else: ?>
								<?php echo link_to($tree['obj']->getName(), 'gallery/show?id=' . $tree['obj']->getObjId()); ?>
							<?php endif; ?>
						<?php endif; ?>
						
					<?php endif; ?>
					
				</li>

                   
            <?php endif; ?>

        <?php endforeach; ?>
	
    <?php endif;?>